/**
 * Copyright (c) 2012 Axa Holding Belgium, SA. All rights reserved.
 * This software is the confidential and proprietary information of the AXA Group.
 */
package chabernac.android.wordbattle.paint.bogglesimple;

import android.graphics.Color;
import chabernac.android.wordbattle.WordRasterContext;
import chabernac.android.wordbattle.model.Word;
import chabernac.android.wordbattle.model.WordRaster;
import chabernac.android.wordbattle.paint.ClearAllDrawable;
import chabernac.android.wordbattle.paint.DrawableComposite;
import chabernac.android.wordbattle.paint.iDrawable;
import chabernac.android.wordbattle.paint.iDrawableFactory;

public class SimpleBoggleDrawableFactory implements iDrawableFactory {

  private iDrawable myClearAllDraweble;
  private iDrawable myWordRasterDrawable;
  
  public SimpleBoggleDrawableFactory(){
  }

  @Override
  public iDrawable createGameDrawable( WordRaster aRaster ) {
    DrawableComposite theComposite = new DrawableComposite();
    
    theComposite.addDrawable( createClearAllDrawable() );
    theComposite.addDrawable( createSelectedLettersDrawable( new Word(WordRasterContext.getInstance().getMediator().getWordRaster().getSelectedLetters() )));
    theComposite.addDrawable( createWordRasterDrawable( aRaster ));
    //theComposite.addDrawable( createSelectedWordsDrawable(aRaster) );
    
    return theComposite;

  }

  private iDrawable createClearAllDrawable() {
    if(myClearAllDraweble == null){
      myClearAllDraweble = new ClearAllDrawable( Color.argb(255, 80, 80, 80));
    }
    return myClearAllDraweble;
  }

  private iDrawable createSelectedLettersDrawable( Word aWord ) {
   return new SelectedWordDrawable(aWord);
  }

  private iDrawable createWordRasterDrawable( WordRaster aRaster ) {
    if(myWordRasterDrawable == null) {
      myWordRasterDrawable = new SimpleBoggleWordRasterDrawable( aRaster );
    }
    return myWordRasterDrawable;
  }

}
